package com.biz.primus.ms.oms.dao.repository;

import com.biz.primus.ms.oms.dao.po.returns.OmsRefund;
import com.biz.primus.ms.oms.dao.po.returns.OmsReturn;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * @author LGJ
 * @date  2017/11/15
 */
public interface OmsRefundRepository extends JpaRepository<OmsRefund,Long>,JpaSpecificationExecutor<OmsRefund> {


    /**
     * 根据退单ID查询退款单
     * @param returnId
     * @return
     */
    OmsRefund findByReturnId(Long returnId);

    /**
     * 根据退款编号获取退款单
     * @param refundCode
     * @return
     */
    OmsRefund findByRefundCode(String refundCode);

    /**
     * 根据退款单编码查询是否存在
     * @param refundCode
     * @return
     */
    @Query("select count(o.id) from OmsRefund o where o.refundCode = ?1")
    int isExistOrder(String refundCode);
}
